package com.research.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class WebConfig  implements WebMvcConfigurer {

    @Value("${upload.accessPath}")
    private String accessPath;
    @Value("${upload.localPath}")
    private String localPath;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry){
        //使用registry去注册地址
        //第一个参数是访问路径，后面别忘了加/**
        //这个的意思是当你访问我这个地址的时候，请你去访问我本地目录下的...这个**就是我本地目录下的哪个东西
        registry.addResourceHandler(accessPath+"**").addResourceLocations("file:"+localPath);

    }
}
